@extends('adminDialog')

@section('content')
    <form action="{{url('admin/member/update/'.$model->id)}}" method="POST" class="J_ajaxForm">
        <input type="hidden" name="_token" value="{{ csrf_token() }}">
        <div class="pop_cont pop_table">
            <table width="100%">
                <tbody>
                <tr>
                    <th><label for="name">账号 <span class="red">*</span></label></th>
                    <td>
                        <input type="text" name="name" id="name" class="input length_2" value="{{$model->name}}" disabled/>
                    </td>
                </tr>
                <tr>
                    <th><label for="real_name">会员类型</label></th>
                    <td>
                        <select name="type" id="type">
                                <option value="1" @if (1 == $model->type)  selected="selected"@endif>注册会员</option>
                                <option value="2" @if (2 == $model->type)  selected="selected"@endif>普通会员</option>
                                <option value="3" @if (3 == $model->type)  selected="selected"@endif>银牌会员</option>
                                <option value="4" @if (4 == $model->type)  selected="selected"@endif>金牌会员</option>
                                <option value="5" @if (5 == $model->type)  selected="selected"@endif>钻石会员</option>
                                <option value="9" @if (9 == $model->type)  selected="selected"@endif>过期会员</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <th><label for="real_name">截止日期</label></th>
                    <td>
                        <input type="date" name="deadline" id="deadline" class="input length_2" value="{{date('Y-m-d', strtotime($model->deadline))}}"/>
                    </td>
                </tr>
                <tr>
                    <th><label for="email">联系电话</label></th>
                    <td>
                        <input type="text" name="email" id="email" class="input length_3" value="{{$model->tel}}" disabled/>
                    </td>
                </tr>
                <tr>
                    <th><label for="email">E-Mail</label></th>
                    <td>
                        <input type="text" name="email" id="email" class="input length_3" value="{{$model->email}}" disabled/>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>

        <div class="pop_bottom cc">
            <button type="reset" class="btn fr" id="J_dialog_close">取消</button>
            <button type="submit" class="btn btn_submit J_ajax_submit_btn fr mr10" id="J_dialog_close">提交</button>
        </div>
    </form>
@stop

@section('style')
    <style>
        .body_none {width: 350px;}
        #upload_btn {cursor:pointer; display: inline-block;}
        #upload_btn img {border-radius: 50%;}
    </style>
@stop

@section('js')
    @parent
    <script src="{{asset('/js/plupload/plupload.full.min.js')}}"></script>
    <script>
        var uploader = new plupload.Uploader({
            browse_button : 'upload_btn',
            url : '{{url('/upimg')}}',
            flash_swf_url : '{{asset('/js/plupload/Moxie.swf')}}',
            silverlight_xap_url: '{{asset('/js/plupload/Moxie.xap')}}',
            filters : {
                mime_types : [
                    {title: '图片文件', extensions: "jpg,gif,png"}
                ],
                max_file_size: '10mb'
            },
            multi_selection : false,
            file_data_name  : 'file',
            multipart_params: {'_token': GV.TOKEN, 'dir': 'avatar'}
        });
        uploader.init();

        uploader.bind('Error', function (uploader, errObject) {
            Wind.dialog.alert(errObject.message);
        });

        uploader.bind('FilesAdded', function (uploader, files) {
            uploader.start();
        });
        uploader.bind('FileUploaded', function (uploader, file, responseObj) {
            var ret = $.parseJSON(responseObj.response);
            if (! ret.id)
                Wind.dialog.alert(ret.message);
            else {
                $('#avatar_id').val(ret.id);
                $('#upload_btn').find('img').attr('src', '{!! url("img/avatar-' + ret.id + '/80-80") !!}');
            }
        });
    </script>
@stop